﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<%@ Import Namespace="ThietBiSo.LinQDB" %>
<%@ Import Namespace="ThietBiSo.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Website - bảng điều khiển
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">
        function submitForm() {
            if (checkForm()) {
                document.forms[0].submit();
            }
        }
        function submitForm1() {

            document.forms[0].submit();

        }
        function checkForm() {
            var flag = true;
            var F = document.forms[0];
            var TieuDe = document.getElementById("TieuDe").value;
            var NDTT = document.getElementById("NoiDungTomTat").value;
            var danhmuc = document.getElementById("ddlDanhMucXayDung").value;

            if (danhmuc == null || danhmuc == "") {
                alert("Chưa chọn danh mục ");
             
                flag = false;

            }
            else if (TieuDe == null || TieuDe == "") {
                alert("Chưa nhập tiêu đề ");
                F.TieuDe.focus();
                flag = false;

            }
            else if (NDTT == null || NDTT == "") {
                alert("Chưa nhập tóm tắt");
                F.NoiDungTomTat.focus();
                flag = false;

            }

            return flag;
        }
    </script>

     <%
   
        MQuangCao mqc = new MQuangCao();
        var vitri = mqc.FindAll_ViTriQuangCao();
        var target = mqc.FindAll_TargetQuangCao();
        var loaiqc = mqc.FindAll_LoaiQuangCao();

        MXayDung_DanhMuc mxd = new MXayDung_DanhMuc();
        var dm = mxd.FindAll_XayDung();
    %>

   <%-- <% int maloaitin = int.Parse(Request.QueryString["cbNhom"]); %>--%>
    <% using (Html.BeginForm("Create", "xaydung", FormMethod.Post, new { @enctype = "multipart/form-data" }))
       { %>
    <%: Html.ValidationSummary(true) %>
    <fieldset>
        <legend class="classFieldSet">Thêm xây dựng </legend>
        <table width="100%">
            <tr style="background-color: #e0e0e0">
                <td class="classCreate">
                   
                    <input type="button" value="Thêm" class="btn" onclick="submitForm();" />
                   
                </td>
                <td>
                    <%: Html.ActionLink("Quay lại", "xaydung")%>
                </td>
            </tr>
           <%-- <tr>
                <td class="tableLabel">
                    Danh mục
                </td>
                <td style="color: Red; font-weight: bold;">
                    <%:Html.Hidden("cbNhom", ViewData["urlcbNhom"])%>
                    <%=ViewData["tenloaitins"]%>
                </td>
            </tr>--%>
           <tr>
             <td class="tableLabel">
                    Danh mục
                </td>
            <td class="tableField">
                    <%: Html.DropDownList("ddlDanhMucXayDung", new SelectList(dm, "MaDanhMuc", "TenDanhMuc"), "Chọn danh mục", new { @style = "width:605px" })%>
                </td>
           </tr>
            <tr>
           
                <td class="tableLabel">
                    Tiêu đề
                </td>
                <td class="tableField">
                    <%:Html.TextBox("TieuDe", null, new { @style = "width:600px" })%>
                </td>
            </tr>
            <tr>
                <td class="tableLabel">
                    Tóm tắt
                </td>
                <td class="tableField">
                    <%:Html.TextArea("NoiDungTomTat", null, new { @style = "width:600px ; height=100px" })%>
                </td>
            </tr>
            <tr>
                <td class="tableLabel">
                    Hình ảnh
                </td>
                <td class="tableField">
                    <%:Html.TextBox("HinhAnh")%>
                    <input type="button" value="Chọn ..." id="btnSelectImg" name="btnSelectImg" />
                    <script type="text/javascript">
                        $(document).ready(function () {
                            $("#btnSelectImg").click(function () {
                                var finder = new CKFinder();
                                finder.selectActionFunction = function (fileUrl) {
                                    $('#HinhAnh').val(fileUrl);
                                };
                                finder.popup();
                            });
                        });
                    </script>
                    <%-- <div style="color: Red">
                        Kích thước hình: (160 x 110) là tốt nhất</div>--%>
                    <%-- <input class="field" type="file" name="fileUpload" id="fileUpload" style="width: 100%;" />--%>
                </td>
            </tr>
          
        </table>
        <div>
            <%= Html.TextArea("ChiTiet", null, new { @name = "ChiTiet" })%>
            <script type="text/javascript">

                CKEDITOR.replace('ChiTiet',
             {
                 htmlEncodeOutput: true,
                 enterMode: CKEDITOR.ENTER_BR,
                 filebrowserImageBrowseUrl: '/ckfinder/ckfinder.html?type=Images',
                 filebrowserImageUploadUrl: '/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Images'
             });
          
            </script>
        </div>
    </fieldset>
    <% } %>
</asp:Content>
